package com.ruoyi.web.controller.kiku;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.kiku.domain.KikuPic;
import com.ruoyi.kiku.domain.model.ImageModel;
import com.ruoyi.kiku.service.IKikuPicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 小鞠图片信息Controller
 *
 * @author TT
 * @date 2025-03-31
 */
@RestController
@RequestMapping("/kiku/pic")
public class KikuPicController extends BaseController
{
    @Autowired
    private IKikuPicService kikuPicService;

    /**
     * 查询小鞠图片信息列表
     */
    @PreAuthorize("@ss.hasPermi('kiku:pic:list')")
    @GetMapping("/list")
    public TableDataInfo list(KikuPic kikuPic)
    {
        startPage();
        List<KikuPic> list = kikuPicService.selectKikuPicList(kikuPic);
        return getDataTable(list);
    }

    /**
     * 导出小鞠图片信息列表
     */
    @PreAuthorize("@ss.hasPermi('kiku:pic:export')")
    @Log(title = "小鞠图片信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KikuPic kikuPic)
    {
        List<KikuPic> list = kikuPicService.selectKikuPicList(kikuPic);
        ExcelUtil<KikuPic> util = new ExcelUtil<KikuPic>(KikuPic.class);
        util.exportExcel(response, list, "小鞠图片信息数据");
    }

    /**
     * 获取小鞠图片信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('kiku:pic:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(kikuPicService.selectKikuPicById(id));
    }

    /**
     * 新增小鞠图片信息
     */
    @PreAuthorize("@ss.hasPermi('kiku:pic:add')")
    @Log(title = "小鞠图片信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KikuPic kikuPic)
    {
        return toAjax(kikuPicService.insertKikuPic(kikuPic));
    }

    /**
     * 修改小鞠图片信息
     */
    @PreAuthorize("@ss.hasPermi('kiku:pic:edit')")
    @Log(title = "小鞠图片信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KikuPic kikuPic)
    {
        return toAjax(kikuPicService.updateKikuPic(kikuPic));
    }

    /**
     * 删除小鞠图片信息
     */
    @PreAuthorize("@ss.hasPermi('kiku:pic:remove')")
    @Log(title = "小鞠图片信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(kikuPicService.deleteKikuPicByIds(ids));
    }
    /**
     * 根据分类查询图片数据
     */
    @PreAuthorize("@ss.hasPermi('kiku:pic:list')")
    @GetMapping("/getCategoryImages")
    public AjaxResult getCategoryImages()
    {
        ImageModel imageModel = kikuPicService.getCategoryImages();
        return success(imageModel);
    }
}
